package com.bawei.yangzongcai___day2.MaiDongFangQi.day15;


import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.bawei.yangzongcai___day2.MVPActivity.JavaMVP;
import com.bawei.yangzongcai___day2.MaiDongFangQi.day15.MMVVPP.V.BasemmvvppActivity;
import com.bawei.yangzongcai___day2.R;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.List;

public class MaiDongFangQi15 extends BasemmvvppActivity implements DoodYueshu.foodviewoo , OnRefreshLoadMoreListener {
    BaseQuaireAdpter adpter;
    private RecyclerView mmvvppReclerview;
    private SmartRefreshLayout smar;
    int yang=1;
    boolean offer=true;
    private com.scwang.smart.refresh.layout.SmartRefreshLayout yangshaoye;


    @Override
    public void showmmvvpp() {

    }

    @Override
    public void haidmmvvpp() {

    }

    @Override
    public void tostmmvvpp(String tosd) {

    }

    @Override
    public int bandlayoutmmvvpp() {
        return R.layout.activity_mai_dong_fang_qi15;
    }

    @Override
    public void initmmvvppView() {
        mmvvppReclerview = findViewById(R.id.mmvvppReclerview);
        smar  =findViewById(R.id.yangshaoye);
        smar.setOnRefreshLoadMoreListener(this);
        mmvvppReclerview.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.VERTICAL));
    }

    @Override
    public void initmmvvppDate() {
        DooPretenter dooPretenter = new DooPretenter(new DooModel(), this);
        dooPretenter.getmvp();
    }

    @Override
    public void initadapteroo(List<JavaMVP.DataBean> dataBeans) {

        if (offer)
        {
            adpter = new BaseQuaireAdpter(dataBeans);
            mmvvppReclerview.setAdapter(adpter);
        }else {
            adpter.getData().clear();
        }
        adpter.getData().addAll(dataBeans);
        adpter.notifyDataSetChanged();
        smar.finishLoadMore();
        smar.finishRefresh();

    }

    private void initView() {
        yangshaoye = findViewById(R.id.yangshaoye);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        offer = false;
        ++yang;
        DooModel dooModel = new DooModel();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
     offer=true;
    }
}
